from django.shortcuts import render

# Create your views here.

# 首页的中间内容视图，API
from rest_framework.generics import ListAPIView
from .models import Banner
from .serializers import BannerModelSerializer
from luffy_city.settings import constants


class BannerListAPIView(ListAPIView):
    queryset = Banner.objects.filter(is_show=True, is_delete=False).order_by("-orders", "-id")[
               :constants.HOME_BANNER_LENGTH]
    serializer_class = BannerModelSerializer

# 首页的头部和底部的视图，API
from .models import Nav
from .serializers import NavModelSerializer


class HeaderNavListAPIView(ListAPIView):
    queryset = Nav.objects.filter(is_show=True, is_delete=False, position=0).order_by("orders", "-id")[
               :constants.HOME_HEADER_LENGTH]
    serializer_class = NavModelSerializer


class FooterNavListAPIView(ListAPIView):
    queryset = Nav.objects.filter(is_show=True, is_delete=False, position=1).order_by("orders", "-id")[
               :constants.HOME_FOOTER_LENGTH]
    serializer_class = NavModelSerializer
